<template>
    <div class="activity-detail f f-ac f-col">
        <Breadcrumb router />
        <div class="activity-detail-body">
            <div class="body-top">
                <Title :label="detail.title" :time="detail.start_time" />
                <div class="f f-ac f-jb mt-20">
                    <img :src="baseUrl+detail.image" class="detail-img" />
                    <div class="detail-info f f-col f-jb">
                        <div class="row">主办单位：{{ detail.admin || "-" }}</div>
                        <div class="row">开始时间：{{ detail.start_time || "-" }}</div>
                        <div class="row">结束时间：{{ detail.end_time || "-" }}</div>
                        <div class="row">活动地点：{{ detail.address || "-" }}</div>
                        <div class="row">固定电话：{{ detail.telphone || "-" }}</div>
                        <My-btn :label="detail.test" bg-color="dark-blue" width="142" height="37"
                            @click="handleSignUp(detail)" />
                        <!-- <My-btn v-else label="活动已结束" bg-color="line-gray" read-only width="142" height="37" /> v-if="detail.state == 1"  -->
                    </div>
                </div>
            </div>
            <div class="body-bottom mt-30">
                <My-btn label="活动详情" bg-color="line-blue" read-only />
                <!-- :poster="baseUrl+detail.image" -->
                <video class="mt-30" :src="baseUrl+detail.video" controls v-if="detail.video" />
                <div class="body-content mt-20" v-html="detail.content" />
                <Action-bar :comment="detail.count" :like="detail.like" :collect="detail.collect" :type="4"
                    :is_like="detail.is_like" :is_collect="detail.is_collect" :id="detail.id" @like="handleLike" />
                <Comment :id="detail.id" @comfirm="handleComment" :type="4" :admin_id="detail.admin_id" />
            </div>
        </div>
    </div>
</template>

<script>
    import {
        actDetail
    } from "@/utils/active/index.js";
    export default {
        data() {
            return {
                baseUrl: process.env.VUE_APP_BASE_API,
                detail: {},
            };
        },

        mounted() {},
        created() {
            this.detail.id = this.$route.query.id
            this.getDetails(this.detail.id);
        },
        methods: {
            // 获取详情
            getDetails(id) {
                this.loading = true;
                let that = this
                actDetail({
                    id
                }).then((response) => {
                    that.detail = response.data
                    that.loading = false;
                    console.log(that.detail)
                });
            },
            // 点击报名
            handleSignUp(v) {
                if (v.test != '活动已结束' && v.test != '进行中') {
                    if (this.detail.registered == this.detail.limit) {
                        this.$message.error("报名已达上限！");
                        return
                    }
                    this.$router.push({
                        path: "/activity/signUp",
                        query: {
                            detail: JSON.stringify(this.detail),
                        },
                    });
                }
            },
            // 评论
            handleComment(v) {
                this.detail.comment = v;
            },
            // 点赞/收藏
            handleLike(v) {
                this.getDetails(v)
            }
        },
    };
</script>

<style lang="scss" scoped>
    .activity-detail {
        width: 100%;

        &-body {
            width: 1200px;

            .body-top {
                width: 100%;
                height: 439px;
                box-sizing: border-box;
                padding: 30px 0;
                border-bottom: 1px solid rgba(70, 110, 197, 0.2);

                .detail-img {
                    width: 633px;
                    height: 296px;
                }

                .detail-info {
                    width: 413px;
                    height: 245px;

                    .row {
                        color: #000;
                        font-size: 18px;
                        line-height: 22px;
                        position: relative;

                        &::before {
                            content: "";
                            position: absolute;
                            left: -5px;
                            display: inline-block;
                            width: 3px;
                            height: 22px;
                            background-color: rgba(70, 110, 197, 0.2);
                        }
                    }
                }
            }

            .body-bottom {
                video {
                    width: 100%;
                    height: 536px;
                    object-fit: cover;
                }

                .body-content {
                    word-break: break-all;
                    padding-bottom: 30px;
                    border-bottom: 1px dashed #d9d9d9;
                }
            }
        }
    }
</style>